{% extends 'hardware/index.html' %}
{% block title %}Instruments{% endblock %}
{% block content %}
<h1 class="page-header">Instruments</h1>
<p>The <strong>state</strong> field on an instrument can be one of the following values:</p>
<dl>
    <dt>DISABLED</dt>
    <dd>The instrument is in configdb, but does not physically exist or is sitting in a box somewhere</dd>
    <dt>MANUAL</dt>
    <dd>The instrument is plugged in, but not ready to do any science</dd>
    <dt>COMMISSIONING</dt>
    <dd>The instrument is currently commissioning, but should not yet be exposed to the network</dd>
    <dt>STANDBY</dt>
    <dd>The instrument has been commissioned and is ready to be switched into SCHEDULABLE when needed</dd>
    <dt>SCHEDULABLE</dt>
    <dd>The instrument is part of the network and is ready for normal operations</dd>
</dl>
<div class="table">
  <table class="table table-striped" id="instruments">
    <thead>
      <tr>
      <th>Instrument Code</th>
      <th>State</th>
      <th>SciCam Codes</th>
      <th>Instrument Type</th>
      <th>SciCam Optical Element Groups</th>
      <th>AutoGuider Code</th>
      <th>AutoGuider Type</th>
      <th>Telescope</th>
      </tr>
    </thead>
    <tbody>
    {% for instrument in object_list %}
      <tr>
        <td><a href="{% url 'instrument-detail' pk=instrument.pk %}">{{ instrument.code }}</a></td>
        <td>{{ instrument.get_state_display }}</td>
        <td>
          {% for science_camera in instrument.science_cameras.all %}
          <div><a href="{% url 'camera-detail' pk=science_camera.pk %}">{{ science_camera.code }}</a></div>
          {% endfor %}
        </td>
        <td><a href="{% url 'instrumenttype-detail' pk=instrument.instrument_type.code %}">{{ instrument.instrument_type }}</a></td>
        <td>
            {% for science_camera in instrument.science_cameras.all %}
            {% for optical_element_group in science_camera.optical_element_groups.all %}
            <div><a href="{% url 'opticalelementgroup-detail' pk=optical_element_group.pk %}">{{ optical_element_group }}</a></div>
            {% endfor %}
            {% endfor %}
        </td>
        <td><a href="{% url 'camera-detail' pk=instrument.autoguider_camera.pk %}">{{ instrument.autoguider_camera.code }}</a></td>
        <td>{{ instrument.autoguider_type }}</td>
        <td><a href="{% url 'telescope-detail' pk=instrument.telescope.pk %}">{{ instrument.telescope }}</a></td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
</div>
{% endblock %}
{% block extra_javascript %}
<script type="text/javascript">
  $(document).ready(function(){
    $('#instruments').DataTable({
      "order": [[0, "asc"]]
    })
  })
</script>
{% endblock %}
